package com.ruoyi.web.TemuProductTraffic.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.TemuProductTraffic.domain.TemuProductTraffic;
import com.ruoyi.web.TemuProductTraffic.service.ITemuProductTrafficService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * TemuProductTrafficController
 * 
 * @author ruoyi
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/TemuProductTraffic/TemuProductTraffic")
public class TemuProductTrafficController extends BaseController
{
    @Autowired
    private ITemuProductTrafficService temuProductTrafficService;




    @PostMapping("/ProductTraffic")
    public AjaxResult instemuevents(String cokie,String mallid) throws IOException {
        temuProductTrafficService.apiinsdatas(cokie,mallid);
        return AjaxResult.success();
    }


    /**
     * 查询TemuProductTraffic列表
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:list')")
    @GetMapping("/list")
    public TableDataInfo list(TemuProductTraffic temuProductTraffic)
    {
        startPage();
        List<TemuProductTraffic> list = temuProductTrafficService.selectTemuProductTrafficList(temuProductTraffic);
        return getDataTable(list);
    }

    /**
     * 导出TemuProductTraffic列表
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:export')")
    @Log(title = "TemuProductTraffic", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TemuProductTraffic temuProductTraffic)
    {
        List<TemuProductTraffic> list = temuProductTrafficService.selectTemuProductTrafficList(temuProductTraffic);
        ExcelUtil<TemuProductTraffic> util = new ExcelUtil<TemuProductTraffic>(TemuProductTraffic.class);
        util.exportExcel(response, list, "TemuProductTraffic数据");
    }

    /**
     * 获取TemuProductTraffic详细信息
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(temuProductTrafficService.selectTemuProductTrafficById(id));
    }

    /**
     * 新增TemuProductTraffic
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:add')")
    @Log(title = "TemuProductTraffic", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TemuProductTraffic temuProductTraffic)
    {
        return toAjax(temuProductTrafficService.insertTemuProductTraffic(temuProductTraffic));
    }

    /**
     * 批量新增TemuProductTraffic
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:add')")
    @Log(title = "TemuProductTraffic", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public AjaxResult batchAdd(@RequestBody List<TemuProductTraffic> list) {
        return toAjax(temuProductTrafficService.insdatas(list));
    }

    /**
     * 修改TemuProductTraffic
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:edit')")
    @Log(title = "TemuProductTraffic", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TemuProductTraffic temuProductTraffic)
    {
        return toAjax(temuProductTrafficService.updateTemuProductTraffic(temuProductTraffic));
    }

    /**
     * 删除TemuProductTraffic
     */
    @PreAuthorize("@ss.hasPermi('TemuProductTraffic:TemuProductTraffic:remove')")
    @Log(title = "TemuProductTraffic", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(temuProductTrafficService.deleteTemuProductTrafficByIds(ids));
    }
}
